package com.jiangyg.devtools.ui.table;

import com.jiangyg.devtools.ui.table.cell.*;

import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 类描述：列描述
 *
 * @author jiangyg
 * @date 2023-08-26
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Column {

    /**
     * 标题
     */
    String title();

    /**
     * 宽度
     */
    int width() default 50;

    /**
     * 排序
     */
    int order() default 1;

    /**
     * 是否可编辑
     */
    boolean editable() default true;

    /**
     * 单元格类型
     */
    Type type() default Type.TextField;

    enum Type {

        CheckBox(CheckBoxCellRenderer.class, CheckBoxCellEditor.class),

        TextField(TextFieldCellRenderer.class, TextFieldCellEditor.class),

        EditorTextField(EditorTextFieldCellRenderer.class, EditorTextFieldCellEditor.class),

        PackageChooser(PackageChooserCellRenderer.class, PackageChooserCellEditor.class),

        JavaBaseTypeComboBox(JavaBaseTypeComboBoxCellRenderer.class, JavaBaseTypeComboBoxCellEditor.class),

        Operation(OperationalCellRenderer.class, OperationalCellEditor.class);

        public final Class<? extends TableCellRenderer> render;

        public final Class<? extends TableCellEditor> editor;

        Type(Class<? extends TableCellRenderer> render) {
            this.render = render;
            this.editor = null;
        }

        Type(Class<? extends TableCellRenderer> render, Class<? extends TableCellEditor> editor) {
            this.render = render;
            this.editor = editor;
        }

    }

}
